import { BaseWindow } from "../../../../component/window/BaseWindow";
import { PageTool } from "../../../../common/global/PageTool";
import { Language } from "../../../../../extend/language/Language";
import { WelcomeListPanel } from "./WelcomeListPanel";
import { ObjCreate } from "../../common/ObjCreate";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { SGuildWelcome } from "../../../../../Message/Game/SGuildWelcome";
import { EOperOption } from "../../../../../Message/Game/EOperOption";
import { GButton } from "../../../../../com/mui/controls/GButton";
//class GuildWelcomeListWindow
    
    export  class GuildWelcomeListWindow extends BaseWindow
    {
        constructor()
        {
            super();
            this._pageTool = new PageTool([], 9);
            this.init();
            this.addEventListener(flash.events.Event.CHANGE, this.onCurPageChangeHandler);
            return;
        }

        /* internal  */init(): void
        {
            this.setSize(590, 430);
            this.title = Language.getString(57204);
            this.titleHeight = 28;
            this._listPanel = new WelcomeListPanel();
            this._listPanel.x = 15;
            this._listPanel.y = 35;
            this.addChild(this._listPanel);
            this._tipTxt = ObjCreate.createTextField("", 0, 370, 590, 20, this, GlobalStyle.textFormat6);
            this._tipTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this._okBtn = ObjCreate.createGButton(Language.getString(57205), 255, 395, 60, 24, this);
            this._okBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onBtnClickHandler);
            return;
        }

        /* internal  */onBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            this.hide();
            return;
        }

        public onCurPageChangeHandler(arg1: Object /* flash.events.Event */): void
        {
            var loc1=this._listPanel.pageBar.currentPage;
            this._listPanel.updateDataProvider(this._pageTool.getByPageNo(loc1));
            return;
        }

        public updateDataProvider(arg1: Array<any>): void
        {
            var loc2=null;
            var loc3=null;
            var loc1=[];
            var loc4=0;
            while (loc4 < arg1.length) 
            {
                loc2 = arg1[loc4];
                (loc3 = new Map<any, any> /* flash.utils.Dictionary */())["index"] = loc4 + 1;
                loc3["guildWelcome"] = loc2;
                loc1.push(loc3);
                ++loc4;
            }
            this._pageTool.array = loc1;
            this._listPanel.pageBar.currentPage = 1;
            this._listPanel.updateDataProvider(this._pageTool.getByPageNo(1));
            this._listPanel.pageBar.maxPage = this._pageTool.pagesCount;
            this.updateTip();
            return;
        }

        /* internal  */getWelcomeDict(arg1: Array<any>): Map<any, any> /* flash.utils.Dictionary */
        {
            var loc2=0;
            var loc3=0;
            var loc4=0;
            var loc5=null;
            var loc1=new Map<any, any> /* flash.utils.Dictionary */();
            var loc6=0;
            while (loc6 < arg1.length) 
            {
                if ((loc5 = arg1[loc6]["guildWelcome"] as SGuildWelcome).option.value() != EOperOption._EOperOptionExp) 
                {
                    if (loc5.option.value() != EOperOption._EOperOptionMoney) 
                    {
                        if (loc5.option.value() == EOperOption._EOperOptionProp) 
                        {
                            loc4 = loc4 + 1;
                        }
                    }
                    else 
                    {
                        loc3 = loc3 + 88;
                    }
                }
                else 
                {
                    loc2 = loc2 + 88;
                }
                loc1["exp"] = loc2;
                loc1["money"] = loc3;
                loc1["prop"] = loc4;
                ++loc6;
            }
            return loc1;
        }

        /* internal  */updateTip(): void
        {
            var loc1=this.getWelcomeDict(this._pageTool.array);
            this._tipTxt.text = Language.getStringByParam(57206, loc1["exp"], loc1["money"], loc1["prop"]);
            return;
        }

        /* internal */ /* var */_listPanel: WelcomeListPanel;

        /* internal */ /* var */_tipTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_okBtn: GButton;

        /* internal */ /* var */_pageTool: PageTool;
    }
